#[derive(Debug)]
enum Coin {
    Penny,
    Nickel,
    Dime,
    Quarter(UsState),
    None,
}
#[derive(Debug)] // 这样可以立刻看到州的名称
enum UsState {
    Alabama,
    Alaska,
    // --snip--
}
fn main() {
    println!("Hello, world!");
    let val = Value_in_cents(Coin::Penny);

    let val: Option<u8> = Value_in_cents(Coin::None);
    let val: Option<u8> = Value_in_cents(Coin::Quarter(UsState::Alabama));
    println!("{:?}", val);
    let five: Option<i32> = dbg!(Some(5));
    println!("{:?}", five);
    let six = plus_one(five);
    println!("{:?}", six);
    let none = plus_one(None);
    let dice_roll = 9;
    match dice_roll {
        3 => add_fancy_hat(),
        7 => remove_fancy_hat(),
        //  other => move_player(other),
        _ => move_player(),
    }

    fn add_fancy_hat() {}
    fn remove_fancy_hat() {}
    fn move_player() {
        println!("num_spaces",)
    }
}
fn Value_in_cents(coin: Coin) -> Option<u8> {
    match coin {
        Coin::Penny => {
            println!("Lucky penny!");
            Some(1)
        }
        Coin::Dime => Some(5),
        Coin::Nickel => Some(10),
        Coin::Quarter(state) => {
            println!("State quarter from {:?}!", state);
            Some(25)
        }
        Coin::None => None,
    }
}
fn plus_one(x: Option<i32>) -> Option<i32> {
    match x {
        None => None,
        Some(i) => Some(i + 1),
    }
}
